﻿
/*
 * PsTFS is a set of PowerShell commands to manage and use Team Foundation Server. PowerShell 
 * effectiveness is combined with the power of TFS API to maximizes TFS capabilities.
 * 
 * Creator : Choulant Noham
 * Mail : choulant@gmail.com
 * Blog : http://choulant.blogspot.com
 * 
 */

using System;
using System.ComponentModel;
using System.Management.Automation;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Configuration.Install;
using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.VersionControl.Client;
using System.IO;
using PowerShell.Host.PsTFS.CdmLet.PsObject;
using Microsoft.TeamFoundation.WorkItemTracking.Client;
using Microsoft.TeamFoundation.WorkItemTracking.Controls;
using System.Windows.Forms;
using Microsoft.PowerShell.Commands.Internal.Format;


namespace PowerShell.Host.PsTFS.CdmLet
{
    /// <summary>
    /// Ajout d'un workitem
    /// </summary>
    [CmdletAttribute("Out", "Workitem")]
    public class OutWorkitemCommand : FrontEndCommandBase
    {
        public OutWorkitemCommand()
        {
        }

        protected override void BeginProcessing()
        {
            try
            {
                InputObject = new PSObject(WI);
                ShowWorkItem(this.InputObject.BaseObject as WorkItem);

                base.BeginProcessing();
            }
            catch { }

        }
        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);
        }
        protected override void EndProcessing()
        {
            try
            {
                base.EndProcessing();
            }
            catch { }
        }
        public override bool Equals(object obj)
        {
            return base.Equals(obj);
        }
        public override int GetHashCode()
        {
            return base.GetHashCode();
        }
        public override string GetResourceString(string baseName, string resourceId)
        {
            return base.GetResourceString(baseName, resourceId);
        }
        protected override PSObject InputObjectCall()
        {
            return base.InputObjectCall();
        }
        protected override void InternalDispose()
        {
            base.InternalDispose();
        }
        protected override PSCmdlet OuterCmdletCall()
        {
            return base.OuterCmdletCall();
        }
        protected override void ProcessRecord()
        {
            try
            {
                base.ProcessRecord();
            }
            catch { }
        }
        protected override void StopProcessing()
        {
            base.StopProcessing();
        }
        public override string ToString()
        {
            return base.ToString();
        }
        protected override void WriteObjectCall(object value)
        {
            base.WriteObjectCall(value);
        }

    // Properties
    [Parameter(Position = 0,ValueFromPipeline = true)]
    public WorkItem WI{get;set;}
    

        public void ShowWorkItem(WorkItem wi)
        {
            WorkItemFormControl fc = new WorkItemFormControl();
            fc.BackColor = System.Drawing.SystemColors.Window;
            fc.Item = wi;
            fc.ReadOnly = false;

            Form new_form = new Form();
            Panel panel = new Panel();
            panel.Dock = DockStyle.Fill;

            new_form.Controls.Add(panel);
            new_form.Width = 800;
            new_form.Height = 600;

            panel.Controls.Add(fc);

            new_form.ShowDialog();

            new_form.Dispose();

        }

        /// <summary>
        /// Object contenant Team Foundation Server 2008
        /// </summary>
        


    }
}
